Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made clone (CTRL+B) in code editor clone only the selection. #24574

Merged
merged 1 commit into from
Feb 16, 2019

Conversation

rxlecky
Copy link
Contributor

@rxlecky rxlecky commented Dec 24, 2018

In code editor, when code is selected, cloning (CTRL+B) now clones only the selected code. The code is cloned to the end of selection. The previous behaviour was to clone the full lines which the selection "touches" to the new line after the end of selection.

Closes #21814.

@rxlecky
Copy link
Contributor Author

rxlecky commented Dec 24, 2018

2018-12-24_02-04-16
Functionality demonstration

@KoBeWi
Copy link
Member

KoBeWi commented Dec 25, 2018

Nice!
Seems to be working as expected, although undo action could get some tweaks. When you duplicate a word and then undo, the caret should appear either:

  • after the first duplicated word (Notepad++)
  • after the last duplicated word, with this word being selected (VS Code)

Here's a recording of the latter behavior:
screen_recorder_plus_video_2018_25_12_02_47_41

With your code right now, doing undo places caret at the end of the whole line, which might be a bit counter-intuitive and bothering. Other than that, good work.

@rxlecky rxlecky force-pushed the issue-21814 branch 2 times, most recently from 644bdc0 to 0255450 Compare December 25, 2018 14:51
In code editor, when code is selected, cloning (CTRL+B) now clones only the selected code. The code is cloned to
the end of selection. The previous behaviour was to clone the full line which the selection "touches" to the new
line after the end of selection.
@rxlecky
Copy link
Contributor Author

rxlecky commented Dec 25, 2018

Thanks for the feedback! Yeah, you are right, the cursor returning to end-of-line is really unintuitive. Fixed that now. I like the second option (VS Code version), but unfortunately that's not really possible. Currently, TextEdit deselects on undo and I don't want to touch that code now just for this tiny feature - that would have to be discussed with the core devs.

godot/scene/gui/text_edit.cpp

Lines 5306 to 5322 in 10e9221

void TextEdit::undo() {
_push_current_op();
if (undo_stack_pos == NULL) {
if (!undo_stack.size())
return; //nothing to undo
undo_stack_pos = undo_stack.back();
} else if (undo_stack_pos == undo_stack.front())
return; // at the bottom of the undo stack
else
undo_stack_pos = undo_stack_pos->prev();
deselect();

For now I implemented the VS Code version without selection. What do you think of it?

2018-12-25_16-23-14

@KoBeWi
Copy link
Member

KoBeWi commented Dec 25, 2018

Seems to work perfectly now. The selection feature isn't necessary for me.
Thanks! Hope it gets merged.

@akien-mga akien-mga added this to the 3.2 milestone Dec 27, 2018
Copy link
Member

@Paulb23 Paulb23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@akien-mga akien-mga modified the milestones: 3.2, 3.1 Feb 16, 2019
@akien-mga akien-mga merged commit 1aadb9f into godotengine:master Feb 16, 2019
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants